#!/usr/bin/expect -f 

set timeout -1
set DSTIP [lindex $argv 0]
set PASSWD [lindex $argv 1]
set SRC_FILE [lindex $argv 2]
set DST_FILE [lindex $argv 3]

spawn scp -r $SRC_FILE $DSTIP:$DST_FILE
expect {
    "*(yes/no)" {send "yes\r";exp_continue}
    "*assword:*" {send "$PASSWD\r"}
    }
expect "100%"
expect eof